package com.qlm.servlet;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.qlm.service.stuInfoService;

public class queryAllStuServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		service(request,response);
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		service(request,response);
	}

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		String osid = request.getParameter("osid");
		List stus = null;
		try {
			stus = new stuInfoService().queryAllStu();
			HttpSession session = request.getSession();
			session.setAttribute("stus", stus);
			if(osid.equals("query")){
				request.getRequestDispatcher("/displayStuInfo.jsp").forward(request, response);
			}else if(osid.equals("modify")){
				request.getRequestDispatcher("/modifyStuInfo.jsp").forward(request, response);
			}else{
				request.getRequestDispatcher("/deleteStuInfo.jsp").forward(request, response);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	
}
